#include <stdio.h>
#include <stdlib.h>

typedef struct
{
	unsigned row;
	unsigned col;
	int t_flag;
	int * data;
}Mat;

void print_matrix(Mat);

int main()
{
	Mat matrix;
	matrix.row = 4;
	matrix.col = 5;
	int matrix_data[100] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
	matrix.data = matrix_data;
	matrix.t_flag = 1;
	print_matrix(matrix);
	matrix.t_flag = 0;
	print_matrix(matrix);
	return 0;
}

void print_matrix(Mat matrix)
{
	int i,j;
	if(matrix.t_flag)
	{
		for(i = 0; i < matrix.row; i++)
		{
			for(j = 0+i; j < matrix.col+i; j++)printf("%d\t",matrix.data[i*matrix.row + j]);
			putchar('\n');
		}
	}
	else
	{
		for(i = 0; i < matrix.col; i++)
		{
			for(j = 0; j < matrix.row; j++)printf("%d\t",matrix.data[j*matrix.row+i+j]);
			putchar('\n');
		}
	}
}
